#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */

typedef struct ListNode ListNode;
bool isPalindrome(struct ListNode* head) {
    ListNode* pcur = head;
    ListNode* prev = head;
    int count = 0;
    while (pcur) {
        pcur = pcur->next;
        count++;
    }
    int arr[count];
    for (int i = 0; i < count; i++) {
        arr[i] = prev->val;
        prev = prev->next;
    }
    int left = 0;
    int right = sizeof(arr) / sizeof(arr[0]) - 1;
    while (left < right)
    {
        if (arr[left] != arr[right])
        {
            return false;
        }
        else
        {
            left++;
            right--;
        }
    }
    return true;
}

//----------------------------------------------------------------------------------------------------------------
